namespace WsusWebAdmin.WsusWrappers
{
    using Microsoft.UpdateServices.Administration;
    using Microsoft.UpdateServices.Internal;
    using Microsoft.UpdateServices.Internal.BaseApi;
    using Microsoft.Win32;
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Collections.Specialized;
    using System.IO;
    using System.Net;
    using System.Net.Mail;
    using System.Runtime.InteropServices;
    using System.Web.Services.Protocols;
    using Microsoft.UpdateServices.Internal.DatabaseAccess;

    public class AuthenticatedAdminDataAccessProxy : AdminDataAccess
    {
        private const int Timeout2Hours = 0x6ddd00;
        private const int Timeout30Minutes = 0x1b7740;
        private const int Timeout3Minutes = 0x2bf20;
        //private UpdateServer updateServer;
        private ApiRemoting ws;
        

        public AuthenticatedAdminDataAccessProxy(string webServiceUrl, NetworkCredential credentials) : base(true)
        {
            //throw new Exception("je bu dup");
            bool flag = false;         
            RegistryKey key = null;
            try
            {
                key = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Update Services\Server\Setup");
                object obj2 = key.GetValue("DisableRemotingCompression");
                if ((obj2 is int) && (((int) obj2) == 1))
                {
                    flag = true;
                }
            }
            catch
            {
            }
            finally
            {
                if (key != null)
                {
                    key.Close();
                }
            }
           
            this.ws = new ApiRemoting();
           
            this.ws.Url = webServiceUrl;
            this.ws.PreAuthenticate = true;

            if (credentials==null)
            {
                this.ws.Credentials = CredentialCache.DefaultCredentials;
            }
            else
            {
                CredentialCache cache = new CredentialCache();
                cache.Add(new Uri(webServiceUrl), "Basic", credentials);
                this.ws.Credentials = cache;
            }
            this.ws.UnsafeAuthenticatedConnectionSharing = true;
            this.ws.Timeout = 0x2bf20;
            //this.ws.Proxy = new WebProxy("localhost", 8888);
            //this.ws.UserAgent = "kopytko";
        }

        public override bool AddNewLanguage(ServerSyncLanguageData newLanguage)
        {
            try
            {
                return this.ws.AddNewLanguage(newLanguage);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return false;
        }

        public override UpdateRevisionId[] ApplyAutomaticUpdateApprovalRule(int ruleId)
        {
            try
            {
                return this.ws.ApplyAutomaticUpdateApprovalRule(ruleId);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override void CatalogSiteGetMetadataAndImport(Guid updateId, byte[][] downloadedFileDigests)
        {
            try
            {
                this.ws.CatalogSiteGetMetadataAndImport(updateId, downloadedFileDigests);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override CompleteAutomaticUpdateApprovalRule CreateInstallApprovalRule(string name)
        {
            try
            {
                return this.ws.CreateInstallApprovalRule(name);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return new CompleteAutomaticUpdateApprovalRule();
        }

        public override void DeleteInstallApprovalRule(int ruleId)
        {
            try
            {
                this.ws.DeleteInstallApprovalRule(ruleId);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void ExecuteGetSigningCertificate(string certificateFile)
        {
            try
            {
                byte[] bytes = this.ws.ExecuteGetSigningCertificate();
                System.IO.File.WriteAllBytes(certificateFile, bytes);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void ExecuteReplicaSPDeleteDeployment(Guid id)
        {
            try
            {
                this.ws.ExecuteReplicaSPDeleteDeployment(id);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void ExecuteSetSelfSigningCertificate()
        {
            try
            {
                this.ws.ExecuteSetSelfSigningCertificate();
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void ExecuteSetSigningCertificate(string pfxFile, byte[] passwordBytes)
        {
            try
            {               
                byte[] pFXFileContent = null;
                if (pfxFile != null)
                {
                    if (!System.IO.File.Exists(pfxFile))
                    {
                        throw new FileNotFoundException(pfxFile);
                    }
                    pFXFileContent = System.IO.File.ReadAllBytes(pfxFile);
                }
                this.ws.ExecuteSetSigningCertificate(pFXFileContent, passwordBytes);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void ExecuteSPAcceptEula(Guid eulaId, string adminName, UpdateRevisionId updateId)
        {
            try
            {
                this.ws.ExecuteSPAcceptEula(eulaId, adminName, updateId);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void ExecuteSPAcceptEulaForReplicaDSS(Guid eulaId)
        {
            try
            {
                this.ws.ExecuteSPAcceptEulaForReplicaDSS(eulaId);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void ExecuteSPAddComputerToTargetGroupAllowMultipleGroups(Guid targetGroupId, string computerId)
        {
            try
            {
                this.ws.ExecuteSPAddComputerToTargetGroupAllowMultipleGroups(targetGroupId, computerId);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void ExecuteSPCancelAllDownloads()
        {
            try
            {
                this.ws.ExecuteSPCancelAllDownloads();
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void ExecuteSPCancelDownload(UpdateRevisionId id)
        {
            try
            {
                this.ws.ExecuteSPCancelDownload(id);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override int ExecuteSPCleanupObsoleteComputers()
        {
            try
            {
                try
                {
                    this.ws.Timeout = 0x6ddd00;
                    return this.ws.ExecuteSPCleanupObsoleteComputers();
                }
                finally
                {
                    this.ws.Timeout = 0x2bf20;
                }
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return 0;
        }

        public override long ExecuteSPCleanupUnneededContentFiles()
        {
            try
            {
                return this.ws.ExecuteSPCleanupUnneededContentFiles();
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return 0L;
        }

        public override void ExecuteSPCompressUpdate(int localUpdateID)
        {
            try
            {
                this.ws.ExecuteSPCompressUpdate(localUpdateID);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override int ExecuteSPCountObsoleteUpdatesToCleanup()
        {
            try
            {
                try
                {
                    this.ws.Timeout = 0x6ddd00;
                    return this.ws.ExecuteSPCountObsoleteUpdatesToCleanup();
                }
                finally
                {
                    this.ws.Timeout = 0x2bf20;
                }
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return 0;
        }

        public override int ExecuteSPCountUpdatesToCompress()
        {
            try
            {
                return this.ws.ExecuteSPCountUpdatesToCompress();
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return 0;
        }

        public override GenericReadableRow ExecuteSPCreateTargetGroup1(string name, Guid parentGroupId)
        {
            try
            {
                return this.ws.ExecuteSPCreateTargetGroup1(name, parentGroupId);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow ExecuteSPCreateTargetGroup2(string name, Guid parentGroupId, Guid id, bool failIfReplica)
        {
            try
            {
                return this.ws.ExecuteSPCreateTargetGroup2(name, parentGroupId, id, failIfReplica);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override int ExecuteSPDeclineExpiredUpdates(string adminName)
        {
            try
            {
                try
                {
                    this.ws.Timeout = 0x6ddd00;
                    return this.ws.ExecuteSPDeclineExpiredUpdates(adminName);
                }
                finally
                {
                    this.ws.Timeout = 0x2bf20;
                }
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return 0;
        }

        public override int ExecuteSPDeclineSupersededUpdates(string adminName)
        {
            try
            {
                try
                {
                    this.ws.Timeout = 0x6ddd00;
                    return this.ws.ExecuteSPDeclineSupersededUpdates(adminName);
                }
                finally
                {
                    this.ws.Timeout = 0x2bf20;
                }
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return 0;
        }

        public override void ExecuteSPDeclineUpdate(Guid updateId, string adminName, bool failIfReplica)
        {
            try
            {
                this.ws.ExecuteSPDeclineUpdate(updateId, adminName, failIfReplica);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void ExecuteSPDeleteComputer(string id)
        {
            try
            {
                this.ws.ExecuteSPDeleteComputer(id);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void ExecuteSPDeleteDeployment(Guid id, string adminName)
        {
            try
            {
                this.ws.ExecuteSPDeleteDeployment(id, adminName);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void ExecuteSPDeleteDownstreamServer(Guid id)
        {
            try
            {
                this.ws.ExecuteSPDeleteDownstreamServer(id);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void ExecuteSPDeleteTargetGroup(Guid id, string adminName, bool failIfReplica)
        {
            try
            {
                this.ws.ExecuteSPDeleteTargetGroup(id, adminName, failIfReplica);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void ExecuteSPDeleteUpdate(int localUpdateID)
        {
            try
            {
                this.ws.ExecuteSPDeleteUpdate(localUpdateID);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void ExecuteSPDeleteUpdateByUpdateID(Guid updateID)
        {
            try
            {
                this.ws.ExecuteSPDeleteUpdateByUpdateID(updateID);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override GenericReadableRow ExecuteSPDeployUpdate1(UpdateRevisionId updateId, int deploymentAction, Guid targetGroupId, DateTime deadline, string adminName, bool isAssigned)
        {
            try
            {
                return this.ws.ExecuteSPDeployUpdate1(updateId, deploymentAction, targetGroupId, deadline, adminName, isAssigned);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow ExecuteSPDeployUpdate2(Guid updateId, int revisionNumber, int deploymentAction, Guid targetGroupId, string adminName, DateTime deadline, bool isAssigned, DateTime goLiveTime, int downloadPriority, Guid deploymentGuid, bool translateSqlException, bool failIfReplica, bool isReplicaSync)
        {
            try
            {
                return this.ws.ExecuteSPDeployUpdate2(updateId, revisionNumber, deploymentAction, targetGroupId, adminName, deadline, isAssigned, goLiveTime, downloadPriority, deploymentGuid, translateSqlException, failIfReplica, isReplicaSync);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[][] ExecuteSPGetAllComputers()
        {
            try
            {
                return this.ws.ExecuteSPGetAllComputers();
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[] ExecuteSPGetAllDownstreamServers(Guid parentServerId, bool includeNestedChildren)
        {
            try
            {
                return this.ws.ExecuteSPGetAllDownstreamServers(parentServerId, includeNestedChildren);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[] ExecuteSPGetAllLanguagesWithEnabledState()
        {
            try
            {
                return this.ws.ExecuteSPGetAllLanguagesWithEnabledState();
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[] ExecuteSPGetAllTargetGroups()
        {
            try
            {
                return this.ws.ExecuteSPGetAllTargetGroups();
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[][] ExecuteSPGetApprovedUpdateMetadata(Guid[] updateCategoryIds, Guid[] updateClassificationIds)
        {
            try
            {
                return this.ws.ExecuteSPGetApprovedUpdateMetadata(updateCategoryIds, updateClassificationIds);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[] ExecuteSPGetCategories(string preferredCulture, bool retrieveUpdateClassifications, DateTime fromSyncDate, DateTime toSyncDate)
        {
            try
            {
                return this.ws.ExecuteSPGetCategories(preferredCulture, retrieveUpdateClassifications, fromSyncDate, toSyncDate);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow ExecuteSPGetCategoryById(string preferredCulture, bool retrieveUpdateClassification, Guid id)
        {
            try
            {
                return this.ws.ExecuteSPGetCategoryById(preferredCulture, retrieveUpdateClassification, id);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[] ExecuteSPGetChildTargetGroups(Guid targetGroupId)
        {
            try
            {
                return this.ws.ExecuteSPGetChildTargetGroups(targetGroupId);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override StringCollection ExecuteSPGetClientsWithRecentNameChange()
        {
            try
            {
                StringCollection strings = new StringCollection();
                strings.AddRange(this.ws.ExecuteSPGetClientsWithRecentNameChange());
                return strings;
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override StringCollection ExecuteSPGetComponentsWithErrors()
        {
            try
            {
                StringCollection strings = new StringCollection();
                strings.AddRange(this.ws.ExecuteSPGetComponentsWithErrors());
                return strings;
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[][] ExecuteSPGetComputerById(string id)
        {
            try
            {
                return this.ws.ExecuteSPGetComputerById(id);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override int ExecuteSPGetComputerCount(string computerTargetScopeXml)
        {
            try
            {
                return this.ws.ExecuteSPGetComputerCount(computerTargetScopeXml);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return 0;
        }

        public override GenericReadableRow[][] ExecuteSPGetComputersHavingInventoryItem(Guid targetGroupId, bool includeSubgroups, string className, string propertyName, string propertyValue)
        {
            try
            {
                return this.ws.ExecuteSPGetComputersHavingInventoryItem(targetGroupId, includeSubgroups, className, propertyName, propertyValue);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[][] ExecuteSPGetComputersInTargetGroup(Guid targetGroupId, bool includeSubgroups)
        {
            try
            {
                return this.ws.ExecuteSPGetComputersInTargetGroup(targetGroupId, includeSubgroups);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override int ExecuteSPGetComputersNotContactedSinceCount(DateTime fromDate)
        {
            try
            {
                return this.ws.ExecuteSPGetComputersNotContactedSinceCount(fromDate);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return 0;
        }

        public override GenericReadableRow[] ExecuteSPGetComputerSummariesForCategory(Guid categoryId)
        {
            try
            {
                return this.ws.ExecuteSPGetComputerSummariesForCategory(categoryId);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[] ExecuteSPGetComputerSummariesForTargetGroup(Guid targetGroupId, bool includeSubgroups)
        {
            try
            {
                return this.ws.ExecuteSPGetComputerSummariesForTargetGroup(targetGroupId, includeSubgroups);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[][] ExecuteSPGetComputerTargetByName(string name)
        {
            try
            {
                return this.ws.ExecuteSPGetComputerTargetByName(name);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override AllConfigurationTableRows ExecuteSPGetConfiguration()
        {
            try
            {
                return this.ws.ExecuteSPGetConfiguration();
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow ExecuteSPGetContentDownloadProgress()
        {
            try
            {
                return this.ws.ExecuteSPGetContentDownloadProgress();
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow ExecuteSPGetDeploymentById(Guid deploymentId)
        {
            try
            {
                return this.ws.ExecuteSPGetDeploymentById(deploymentId);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[] ExecuteSPGetDeployments(string updateScopeXml, string preferredCulture, ExtendedPublicationState publicationState)
        {
            try
            {
                return this.ws.ExecuteSPGetDeployments(updateScopeXml, preferredCulture, (int) publicationState);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[] ExecuteSPGetDeploymentsByUpdate1(UpdateRevisionId id)
        {
            try
            {
                return this.ws.ExecuteSPGetDeploymentsByUpdate1(id);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[] ExecuteSPGetDeploymentsByUpdate2(UpdateRevisionId id, Guid targetGroupId)
        {
            try
            {
                return this.ws.ExecuteSPGetDeploymentsByUpdate2(id, targetGroupId);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[] ExecuteSPGetDeploymentsByUpdate3(UpdateRevisionId id, Guid targetGroupId, int deploymentAction, DateTime fromDeploymentDate, DateTime toDeploymentDate)
        {
            try
            {
                return this.ws.ExecuteSPGetDeploymentsByUpdate3(id, targetGroupId, deploymentAction, fromDeploymentDate, toDeploymentDate);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow ExecuteSPGetDownstreamServer(Guid id)
        {
            try
            {
                return this.ws.ExecuteSPGetDownstreamServer(id);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[][] ExecuteSPGetDownstreamServerRollupSummary(Guid serverId)
        {
            try
            {
                return this.ws.ExecuteSPGetDownstreamServerRollupSummary(serverId);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[] ExecuteSPGetDownstreamServersInTargetGroup(Guid targetGroupId)
        {
            try
            {
                return this.ws.ExecuteSPGetDownstreamServersInTargetGroup(targetGroupId);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override EmailNotificationConfigurationRow ExecuteSPGetEmailNotificationConfiguration()
        {
            try
            {
                return this.ws.ExecuteSPGetEmailNotificationConfiguration();
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override MailAddressCollection ExecuteSPGetEmailNotificationRecipients(EmailNotificationType value)
        {
            try
            {
                MailAddressCollection addresss = new MailAddressCollection();
                string addresses = this.ws.ExecuteSPGetEmailNotificationRecipients(value);
                if ((addresses != null) && (addresses.Length > 0))
                {
                    addresss.Add(addresses);
                }
                return addresss;
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow ExecuteSPGetEulaAcceptances(Guid id)
        {
            try
            {
                return this.ws.ExecuteSPGetEulaAcceptances(id);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override byte[] ExecuteSPGetEulaFile(string preferredCulture, Guid id, Guid updateId, int revisionNumber)
        {
            try
            {
                return this.ws.ExecuteSPGetEulaFile(preferredCulture, id, updateId, revisionNumber);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override ExportData ExecuteSPGetExportData()
        {
            try
            {
                return this.ws.ExecuteSPGetExportData();
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override ExportUpdateData ExecuteSPGetExportUpdateData(int revisionId)
        {
            try
            {
                return this.ws.ExecuteSPGetExportUpdateData(revisionId);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override int ExecuteSPGetFailedToDownloadUpdatesCount()
        {
            try
            {
                return this.ws.ExecuteSPGetFailedToDownloadUpdatesCount();
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return 0;
        }

        public override GenericReadableRow[] ExecuteSPGetFrontEndServers()
        {
            try
            {
                return this.ws.ExecuteSPGetFrontEndServers();
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[][] ExecuteSPGetInstallableItems(UpdateRevisionId id)
        {
            try
            {
                return this.ws.ExecuteSPGetInstallableItems(id);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[][] ExecuteSPGetInventoryItemsForComputer(string computerId)
        {
            try
            {
                return this.ws.ExecuteSPGetInventoryItemsForComputer(computerId);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[] ExecuteSPGetInventorySummary(Guid targetGroupId, bool includeSubgroups, string className, string propertyName)
        {
            try
            {
                return this.ws.ExecuteSPGetInventorySummary(targetGroupId, includeSubgroups, className, propertyName);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override string[] ExecuteSPGetLanguagesForUpdate(UpdateRevisionId id)
        {
            try
            {
                return this.ws.ExecuteSPGetLanguagesForUpdate(id);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override int ExecuteSPGetLatestRevisionNumberForUpdate(Guid updateId)
        {
            try
            {
                return this.ws.ExecuteSPGetLatestRevisionNumberForUpdate(updateId);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return 0;
        }

        public override int[] ExecuteSPGetObsoleteUpdatesToCleanup()
        {
            try
            {
                try
                {
                    this.ws.Timeout = 0x6ddd00;
                    return this.ws.ExecuteSPGetObsoleteUpdatesToCleanup();
                }
                finally
                {
                    this.ws.Timeout = 0x2bf20;
                }
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[] ExecuteSPGetParentCategories(string preferredCulture, Guid childUpdateId, int childRevisionNumber)
        {
            try
            {
                return this.ws.ExecuteSPGetParentCategories(preferredCulture, childUpdateId, childRevisionNumber);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow ExecuteSPGetParentTargetGroup(Guid targetGroupId)
        {
            try
            {
                return this.ws.ExecuteSPGetParentTargetGroup(targetGroupId);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow ExecuteSPGetParentUpdateClassification(string preferredCulture, Guid childUpdateId, int childRevisionNumber)
        {
            try
            {
                return this.ws.ExecuteSPGetParentUpdateClassification(preferredCulture, childUpdateId, childRevisionNumber);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override int ExecuteSPGetPreviousRevision(Guid updateId, int revisionNumber)
        {
            try
            {
                return this.ws.ExecuteSPGetPreviousRevision(updateId, revisionNumber);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return 0;
        }

        public override GenericReadableRow[] ExecuteSPGetProgramKeys()
        {
            try
            {
                return this.ws.ExecuteSPGetProgramKeys();
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override CompleteUpdates ExecuteSPGetRevisions(string preferredCulture, Guid updateId)
        {
            try
            {
                return this.ws.ExecuteSPGetRevisions(preferredCulture, updateId);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override string ExecuteSPGetSdpXmlForUpdate(Guid updateId, int revisionNumber)
        {
            try
            {
                return this.ws.ExecuteSPGetSdpXmlForUpdate(updateId, revisionNumber);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return string.Empty;
        }

        public override GenericReadableRow[] ExecuteSPGetSubcategories(string preferredCulture, Guid categoryId)
        {
            try
            {
                return this.ws.ExecuteSPGetSubcategories(preferredCulture, categoryId);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[] ExecuteSPGetSummariesPerComputer(string updateScopeXml, string computerTargetScopeXml, string preferredCulture, ExtendedPublicationState publicationState)
        {
            try
            {
                return this.ws.ExecuteSPGetSummariesPerComputer(updateScopeXml, computerTargetScopeXml, preferredCulture, (int) publicationState);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[] ExecuteSPGetSummariesPerUpdate(Guid updateId, string computerTargetScopeXml)
        {
            try
            {
                return this.ws.ExecuteSPGetSummariesPerUpdate_SingleUpdate(updateId, computerTargetScopeXml);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[] ExecuteSPGetSummariesPerUpdate(string updateScopeXml, string computerTargetScopeXml, string preferredCulture, ExtendedPublicationState publicationState)
        {
            try
            {
                return this.ws.ExecuteSPGetSummariesPerUpdate(updateScopeXml, computerTargetScopeXml, preferredCulture, (int) publicationState);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow ExecuteSPGetTargetGroupById(Guid id)
        {
            try
            {
                return this.ws.ExecuteSPGetTargetGroupById(id);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[] ExecuteSPGetTargetGroupsForComputer(string computerId)
        {
            try
            {
                return this.ws.ExecuteSPGetTargetGroupsForComputer(computerId);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[] ExecuteSPGetTargetGroupSummariesForUpdate(Guid updateId, bool includeSubgroups)
        {
            try
            {
                return this.ws.ExecuteSPGetTargetGroupSummariesForUpdate(updateId, includeSubgroups);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[] ExecuteSPGetTopLevelCategories(string preferredCulture)
        {
            try
            {
                return this.ws.ExecuteSPGetTopLevelCategories(preferredCulture);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[] ExecuteSPGetTotalSummaryForCategory(Guid categoryId)
        {
            try
            {
                return this.ws.ExecuteSPGetTotalSummaryForCategory(categoryId);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[] ExecuteSPGetTotalSummaryForComputer(string computerId, string updateScopeXml, string preferredCulture)
        {
            try
            {
                return this.ws.ExecuteSPGetTotalSummaryForComputer(computerId, updateScopeXml, preferredCulture);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[] ExecuteSPGetTotalUpdateSummaryForTargetGroup(Guid targetGroupId, bool includeSubgroups)
        {
            try
            {
                return this.ws.ExecuteSPGetTotalUpdateSummaryForTargetGroup(targetGroupId, includeSubgroups);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override CompleteUpdates ExecuteSPGetUpdateById(string preferredCulture, UpdateRevisionId id)
        {
            try
            {
                return this.ws.ExecuteSPGetUpdateById(preferredCulture, id);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override int ExecuteSPGetUpdateCount(string updateScopeXml, string preferredCulture, ExtendedPublicationState publicationState)
        {
            try
            {
                return this.ws.ExecuteSPGetUpdateCount(updateScopeXml, preferredCulture, (int) publicationState);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return 0;
        }

        public override GenericReadableRow[] ExecuteSPGetUpdateInstallationInfoForComputer(string computerId, string updateScopeXml, string preferredCulture, ExtendedPublicationState publicationState)
        {
            try
            {
                return this.ws.ExecuteSPGetUpdateInstallationInfoForComputer(computerId, updateScopeXml, preferredCulture, (int) publicationState);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[] ExecuteSPGetUpdateInstallationInfoForTargetGroup(Guid updateId, Guid targetGroupId, bool includeSubgroups)
        {
            try
            {
                return this.ws.ExecuteSPGetUpdateInstallationInfoForTargetGroup(updateId, targetGroupId, includeSubgroups);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[] ExecuteSPGetUpdateInstallationInfoForUpdate(Guid updateId, string computerTargetScopeXml)
        {
            try
            {
                return this.ws.ExecuteSPGetUpdateInstallationInfoForUpdate(updateId, computerTargetScopeXml);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override CompleteUpdates ExecuteSPGetUpdatesBundledByUpdate(string preferredCulture, UpdateRevisionId id)
        {
            try
            {
                return this.ws.ExecuteSPGetUpdatesBundledByUpdate(preferredCulture, id);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override CompleteUpdates ExecuteSPGetUpdatesByCategory(string preferredCulture, Guid categoryId, int approvedStates, string updateType, int maxResultCount)
        {
            try
            {
                return this.ws.ExecuteSPGetUpdatesByCategory(preferredCulture, categoryId, approvedStates, updateType, maxResultCount);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[][] ExecuteSPGetUpdateServerStatus(UpdateSources updateSources, bool includeDownstreamComputers, string updateScopeXml, string computerTargetScopeXml, string preferredCulture, ExtendedPublicationState publicationState, UpdateServerStatusPropertiesToGet propertiesToGet)
        {
            try
            {
                return this.ws.ExecuteSPGetUpdateServerStatus((int) updateSources, includeDownstreamComputers, updateScopeXml, computerTargetScopeXml, preferredCulture, (int) publicationState, (int) propertiesToGet);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override CompleteUpdates ExecuteSPGetUpdatesRequiredByUpdate(string preferredCulture, UpdateRevisionId id)
        {
            try
            {
                return this.ws.ExecuteSPGetUpdatesRequiredByUpdate(preferredCulture, id);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override CompleteUpdates ExecuteSPGetUpdatesSupersededByUpdate(string preferredCulture, UpdateRevisionId id)
        {
            try
            {
                return this.ws.ExecuteSPGetUpdatesSupersededByUpdate(preferredCulture, id);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override CompleteUpdates ExecuteSPGetUpdatesThatBundleUpdate(string preferredCulture, UpdateRevisionId id)
        {
            try
            {
                return this.ws.ExecuteSPGetUpdatesThatBundleUpdate(preferredCulture, id);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override CompleteUpdates ExecuteSPGetUpdatesThatRequireUpdate(string preferredCulture, UpdateRevisionId id)
        {
            try
            {
                return this.ws.ExecuteSPGetUpdatesThatRequireUpdate(preferredCulture, id);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override CompleteUpdates ExecuteSPGetUpdatesThatSupersedeUpdate(string preferredCulture, UpdateRevisionId id)
        {
            try
            {
                return this.ws.ExecuteSPGetUpdatesThatSupersedeUpdate(preferredCulture, id);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override int[] ExecuteSPGetUpdatesToCompress()
        {
            try
            {
                return this.ws.ExecuteSPGetUpdatesToCompress();
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[] ExecuteSPGetUpdateSummariesForCategory(Guid categoryId)
        {
            try
            {
                return this.ws.ExecuteSPGetUpdateSummariesForCategory(categoryId);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[] ExecuteSPGetUpdateSummariesForTargetGroup(Guid targetGroupId, bool includeSubgroups)
        {
            try
            {
                return this.ws.ExecuteSPGetUpdateSummariesForTargetGroup(targetGroupId, includeSubgroups);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[] ExecuteSPGetUpdateSummaryForSingleTargetGroup(Guid updateId, Guid targetGroupId, bool includeSubgroups)
        {
            try
            {
                return this.ws.ExecuteSPGetUpdateSummaryForSingleTargetGroup(updateId, targetGroupId, includeSubgroups);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override string ExecuteSPGetXmlForUpdate(Guid updateId, int revisionNumber)
        {
            try
            {
                return this.ws.ExecuteSPGetXmlForUpdate(updateId, revisionNumber);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return string.Empty;
        }

        public override bool ExecuteSPHasApprovalsChanged(string cookie)
        {
            try
            {
                return this.ws.ExecuteSPHasApprovalsChanged(cookie);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return false;
        }

        public override GenericReadableRow[] ExecuteSPLoadReportingEventAttributes()
        {
            try
            {
                return this.ws.ExecuteSPLoadReportingEventAttributes();
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[][] ExecuteSPPreregisterComputer(string computerName, byte[] sid)
        {
            try
            {
                return this.ws.ExecuteSPPreregisterComputer(computerName, sid);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override void ExecuteSPPurgeReportingEventInstances(string computerId, Guid updateId, string targetGroupId, DateTime fromDate, DateTime toDate)
        {
            try
            {
                this.ws.ExecuteSPPurgeReportingEventInstances(computerId, updateId, targetGroupId, fromDate, toDate);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void ExecuteSPRefreshDeployments(Guid updateId)
        {
            try
            {
                this.ws.ExecuteSPRefreshDeployments(updateId);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void ExecuteSPRemoveComputerFromTargetGroup(Guid targetGroupId, string computerId)
        {
            try
            {
                this.ws.ExecuteSPRemoveComputerFromTargetGroup(targetGroupId, computerId);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void ExecuteSPRemoveDownstreamServerFromTargetGroup(Guid targetGroupId, string downstreamServerId)
        {
            try
            {
                this.ws.ExecuteSPRemoveDownstreamServerFromTargetGroup(targetGroupId, downstreamServerId);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void ExecuteSPRemoveFrontEndServer(string serverName)
        {
            try
            {
                this.ws.ExecuteSPRemoveFrontEndServer(serverName);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void ExecuteSPResumeAllDownloads()
        {
            try
            {
                this.ws.ExecuteSPResumeAllDownloads();
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void ExecuteSPResumeDownload(UpdateRevisionId id)
        {
            try
            {
                this.ws.ExecuteSPResumeDownload(id);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void ExecuteSPScheduleEmailNotification(EmailNotificationType emailNotificationType, TimeSpan scheduledTimeOfDay, EmailStatusNotificationFrequency frequency)
        {
            try
            {
                this.ws.ExecuteSPScheduleEmailNotification((int) emailNotificationType, scheduledTimeOfDay, (int) frequency);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override GenericReadableRow[][] ExecuteSPSearchComputers(string computerTargetScopeXml)
        {
            try
            {
                return this.ws.ExecuteSPSearchComputers(computerTargetScopeXml);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override EventHistoryTableRow[] ExecuteSPSearchEventHistory(EventHistoryFilter eventHistoryFilter)
        {
            try
            {
                return this.ws.ExecuteSPSearchEventHistory(eventHistoryFilter);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override CompleteUpdates ExecuteSPSearchUpdates(string updateScopeXml, string preferredCulture, ExtendedPublicationState publicationState)
        {
            try
            {
                return this.ws.ExecuteSPSearchUpdates(updateScopeXml, preferredCulture, (int) publicationState);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override void ExecuteSPSetConfiguration(ConfigurationTableRow row, IDictionary changedLanguages, IEnumerable<ProgramKey> programKeys)
        {
            try
            {
                if (row == null)
                {
                    throw new ArgumentNullException("row");
                }
                if (changedLanguages == null)
                {
                    throw new ArgumentNullException("changedLanguages");
                }
                ArrayList list = new ArrayList();
                ArrayList list2 = new ArrayList();
                ArrayList list3 = new ArrayList();
                ArrayList list4 = new ArrayList();
                List<ProgramKey> list5 = null;
                foreach (object obj2 in changedLanguages.Keys)
                {
                    LanguageStates states = (LanguageStates) changedLanguages[obj2];
                    if (states != null)
                    {
                        if (states.Enabled)
                        {
                            list.Add(obj2);
                        }
                        else
                        {
                            list2.Add(obj2);
                        }
                        if (states.UssEnabled)
                        {
                            list3.Add(obj2);
                        }
                        else
                        {
                            list4.Add(obj2);
                        }
                    }
                }
                if (programKeys != null)
                {
                    list5 = new List<ProgramKey>(programKeys);
                }
                else
                {
                    list5 = new List<ProgramKey>();
                }
                this.ws.ExecuteSPSetConfiguration(row, list.ToArray(), list2.ToArray(), list3.ToArray(), list4.ToArray(), list5.ToArray());
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void ExecuteSPSetEmailNotificationConfiguration(EmailNotificationConfigurationRow setting)
        {
            try
            {
                this.ws.ExecuteSPSetEmailNotificationConfiguration(setting);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void ExecuteSPSetEmailNotificationRecipients(MailAddressCollection mc, EmailNotificationType syncType)
        {
            try
            {
                string recipients = string.Empty;
                if (mc != null)
                {
                    recipients = mc.ToString();
                }
                this.ws.ExecuteSPSetEmailNotificationRecipients(recipients, syncType);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void ExecuteSPSetRollupConfiguration(bool doDetailedRollup, Guid rollupResetGuid)
        {
            try
            {
                this.ws.ExecuteSPSetRollupConfiguration(doDetailedRollup, rollupResetGuid);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override GenericReadableRow[][] ExecuteSPSimpleSearchComputers(string name)
        {
            try
            {
                return this.ws.ExecuteSPSimpleSearchComputers(name);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override CompleteUpdates ExecuteSPSimpleSearchUpdates(string preferredCulture, string searchText)
        {
            try
            {
                return this.ws.ExecuteSPSimpleSearchUpdates(preferredCulture, searchText);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override void ExecuteSPWakeUpResetAgent()
        {
            try
            {
                this.ws.ExecuteSPWakeUpResetAgent();
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void ExecuteSPWakeUpRollupAgent()
        {
            try
            {
                this.ws.ExecuteSPWakeUpRollupAgent();
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override CompleteAutomaticUpdateApprovalRule[] GetAutomaticUpdateApprovalRules(string preferredCulture)
        {
            try
            {
                return this.ws.GetAutomaticUpdateApprovalRules(preferredCulture);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override UpdateServerUserRole GetCurrentUserRole()
        {
            try
            {
                return (UpdateServerUserRole) this.ws.GetCurrentUserRole();
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return UpdateServerUserRole.Unauthorized;
        }

        public override void GetDatabaseConfiguration(out string serverName, out string databaseName, out string wmsdeInstanceName)
        {
            serverName = string.Empty;
            databaseName = string.Empty;
            wmsdeInstanceName = string.Empty;
            try
            {
                serverName = this.ws.GetDatabaseConfiguration(out databaseName, out wmsdeInstanceName);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override bool GetResetStateMachineNeededFlag()
        {
            try
            {
                return this.ws.GetResetStateMachineNeededFlag();
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return false;
        }

        public override string GetServerProtocolVersion()
        {
            try
            {
                return this.ws.GetServerProtocolVersion();
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[] GetServerSyncProgress()
        {
            try
            {
                return this.ws.GetServerSyncProgress();
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override string GetServerVersion()
        {
            try
            {
                return this.ws.GetServerVersion();
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override SubscriptionTableRow GetSubscription()
        {
            try
            {
                return this.ws.GetSubscription();
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override GenericReadableRow[] GetSubscriptionCategories(string preferredCulture, bool retrieveUpdateClassifications)
        {
            try
            {
                return this.ws.GetSubscriptionCategories(preferredCulture, retrieveUpdateClassifications);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return null;
        }

        public override DateTime GetSubscriptionNextSynchronizationTime()
        {
            try
            {
                return this.ws.GetSubscriptionNextSynchronizationTime();
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return DateTime.MinValue;
        }

        public override int GetSubscriptionState()
        {
            try
            {
                return this.ws.GetSubscriptionState();
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return 0;
        }

        public override bool HasProxyPassword()
        {
            try
            {
                return this.ws.HasProxyPassword();
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return false;
        }

        public override bool HasSmtpUserPassword()
        {
            try
            {
                return this.ws.HasSmtpUserPassword();
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return false;
        }

        public override void ImportUpdate(int ussRevLocalId, string xmlUpdateBlob, byte[] xmlUpdateBlobCompressed, string xmlSdpBlob, out int localRevisionId)
        {
            localRevisionId = 0;
            try
            {
                localRevisionId = this.ws.ImportUpdate(ussRevLocalId, xmlUpdateBlob, xmlUpdateBlobCompressed, xmlSdpBlob);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void ImportUpdateForPublishing(string susXml, string uspXml, ServerSyncUrlData[] urlData, bool sdpOnly)
        {
            try
            {
                this.ws.ImportUpdateForPublishing(susXml, uspXml, urlData, sdpOnly);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void SendTestEmail(string emailLanguage, string smtpUserName, string senderEmailAddress, string smtpHostName, int smtpPort, string recipients)
        {
            try
            {
                this.ws.SendTestEmail(emailLanguage, smtpUserName, senderEmailAddress, smtpHostName, smtpPort, recipients);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void SetAutomaticUpdateApprovalRule(int ruleId, string name, bool enabled, int action, Guid[] updateClassificationIds, Guid[] categoryIds, Guid[] targetGroupIds)
        {
            try
            {
                this.ws.SetAutomaticUpdateApprovalRule(ruleId, name, enabled, action, updateClassificationIds, categoryIds, targetGroupIds);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void SetAutomaticUpdateApprovalRule(int ruleId, string name, bool enabled, int action, Guid[] updateClassificationIds, Guid[] categoryIds, Guid[] targetGroupIds, int apiVersion, AutomaticUpdateApprovalDeadline deadline)
        {
            try
            {
                this.ws.SetAutomaticUpdateApprovalRule(ruleId, name, enabled, action, updateClassificationIds, categoryIds, targetGroupIds, apiVersion, deadline);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void SetProxyPassword(byte[] passwordBytes)
        {
            try
            {
                try
                {                    
                    this.ws.SetProxyPassword(passwordBytes);
                }
                finally
                {
                    if (passwordBytes != null)
                    {
                        Array.Clear(passwordBytes, 0, passwordBytes.Length);
                    }
                }
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void SetSmtpUserPassword(byte[] passwordBytes)
        {
            try
            {               
                this.ws.SetSmtpUserPassword(passwordBytes);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void SetSubscription(SubscriptionTableRow subscription, Guid[] categoryIds, Guid[] updateClassificationIds, string userName)
        {
            try
            {
                this.ws.SetSubscription(subscription, categoryIds, updateClassificationIds, userName);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void SetSubscriptionFrequency(int numberOfSynchronizationsPerDay)
        {
            try
            {
                this.ws.SetSubscriptionFrequency(numberOfSynchronizationsPerDay);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void SetSubscriptionLastSynchronizationTime(DateTime lastSynchronizationTime)
        {
            try
            {
                this.ws.SetSubscriptionLastSynchronizationTime(lastSynchronizationTime);
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override uint SignCabForPublishing(string filePath)
        {
            try
            {
                try
                {
                    this.ws.Timeout = 0x6ddd00;
                    return this.ws.SignCabForPublishing(filePath);
                }
                finally
                {
                    this.ws.Timeout = 0x2bf20;
                }
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return 0;
        }

        public override uint SignCabForPublishingWithTimeStampOption(string filePath, bool signWithoutTimeStamp)
        {
            try
            {
                try
                {
                    this.ws.Timeout = 0x6ddd00;
                    return this.ws.SignCabForPublishingWithTimeStampOption(filePath, signWithoutTimeStamp);
                }
                finally
                {
                    this.ws.Timeout = 0x2bf20;
                }
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
            return 0;
        }

        public override void StartSubscriptionManually()
        {
            try
            {
                this.ws.StartSubscriptionManually();
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void StartSubscriptionManuallyForCategoryOnly()
        {
            try
            {
                this.ws.StartSubscriptionManuallyForCategoryOnly();
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void StartWSUSService()
        {
            try
            {
                this.ws.StartWSUSService();
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void StopSubscription()
        {
            try
            {
                this.ws.StopSubscription();
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }

        public override void StopWSUSService()
        {
            try
            {
                this.ws.StopWSUSService();
            }
            catch (SoapException exception)
            {
                SoapExceptionProcessor.DeserializeAndThrow(exception);
            }
        }
    }
}

